﻿using System.Web.Mvc;
using System.Web.Routing;

namespace UrlAndRoutes
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapMvcAttributeRoutes(); // needed for the attribute based routing in Controllers.
            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute("NewRoute", "App/Do{Action}", new { controller = "home" });
            routes.MapRoute("MyRoute", "{controller}/{action}", null, new[] { "UrlAndRoutes.Controllers" });

            routes.MapRoute("MyOtherRoute", "App/{action}",
                new { controller = "home", action = "Index", id = UrlParameter.Optional }, // using default values for controller and action
                new[] { "UrlAndRoutes.Controllers" }
                ); // same as below but more simple and clean

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);
        }
    }
}
